package com.webex.ta.hydra.gui.search;

import com.webex.ta.hydra.gui.GuiPackage;
import com.webex.ta.hydra.gui.search.SearchComponent;
import com.webex.ta.hydra.gui.HydraEditorPane;
import com.webex.ta.hydra.gui.project.HydraProjectSuite;
import com.webex.ta.hydra.gui.action.ActionHandler;
import com.webex.ta.hydra.gui.action.ActionNames;

import java.util.Set;
import java.util.HashSet;
import java.awt.event.ActionEvent;

/**
 * Author: Vegaz
 * Date: 2010-10-28
 * Time: 13:04:26
 */
public class FindAction implements ActionHandler {
    private static Set<String> commands = new HashSet<String>();

    static {
        commands.add(ActionNames.FIND);
    }

    public Set<String> getActionNames() {
        return commands;
    }

    public void doAction(ActionEvent e) {

        HydraProjectSuite project = GuiPackage.getInstance().getActiveProject();
        if (project == null) return;
        HydraEditorPane editorPane = project.getEditorPane();

        if(editorPane != null) {
            editorPane.stopEdit();
            SearchComponent search = new SearchComponent(editorPane);

            editorPane.setHeaderPanel(search);
            search.requestFocus();
        }
    }
}
